<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    function cook(){
        return 666;
    }
    cook();
    console.log(cook());

    //求任意两个数的和
    function getSum(num1,num2){
        return num1 + num2;
    }
    getSum(1,100);
    console.log(getSum(1,100));

    // 求任意两个数的最大值
    function getMax(num1,num2){
        return num1 > num2 ?num1 :num2;
        // if(num1>num2){
        //     return num1;
        // }else return num2;
    }
    console.log(getMax(3,5));

    // 求数组中的最大值
    function getArrMax1(){
        var arr = [5,2,99,101,67,77];
        var numMax = 0;
        for(var i =0 ; i<arr.length;i++){
            if(arr[i]>=numMax){
                numMax = arr[i];
            }
        }
        return numMax;
    }
    console.log(getArrMax1());
    // 在实际开发中经常用一个变量接收函数的返回结果，使用简单
    function getArrMax2(arr){
        var max = arr[0];
        for(var i = 0;i<arr.length;i++){
            if(arr[i]>max){
                max = arr[i];

            }        
        }
        return max;
    }
    console.log(getArrMax2([5,2,99,101,67,77]));
    
    //求任意两个数字的加减乘除
    function getResult(num1,num2){
        return [num1+num2,num1-num2,num1*num2,num1/num2];
    }
    console.log(getResult(20,10));


</script>
<body>
    
</body>
</html>